package main

import (
	"fmt"
	"net/rpc"
	"shop/grpc_test/serv/inter"
)

type HelloServerClient struct {
	*rpc.Client
}

func (p *HelloServerClient) Hello(req string, reply *string) error {
	return p.Client.Call(inter.HelloServiceName+".hello", req, reply)
}

func DialHelloService(network, addr string) (*HelloServerClient, error) {
	client, err := rpc.Dial(network, addr)
	if err != nil {
		panic("dial" + err.Error())
	}
	return &HelloServerClient{
		client,
	}, nil
}

func main() {
	client, err := DialHelloService("tcp", ":8888")
	if err != nil {
		return
	}
	var reply *string
	client.Hello("xxx", reply)
	fmt.Println(reply)
}
